<?xml version="1.0" encoding="utf-8"?>
<!-- openEHR Release 1.0.1 Archetype  XML schema -->
<!-- Authored by Ocean Informatics 2007.04.13  -->
<xs:schema xmlns="http://schemas.openehr.org/v1" xmlns:xs="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://schemas.openehr.org/v1" elementFormDefault="qualified" version="1.0.1"
	id="Archetype.xsd">
	<xs:include schemaLocation="Resource.xsd"/>
	<xs:element name="archetype" type="ARCHETYPE"/>
	<xs:complexType name="ARCHETYPE">
		<xs:complexContent>
			<xs:extension base="AUTHORED_RESOURCE">
				<xs:sequence>
					<xs:element name="uid" type="HIER_OBJECT_ID" minOccurs="0"/>
					<xs:element name="archetype_id" type="ARCHETYPE_ID"/>
					<xs:element name="adl_version" type="xs:string" minOccurs="0"/>
					<xs:element name="concept" type="xs:string"/>
					<xs:element name="parent_archetype_id" type="ARCHETYPE_ID" minOccurs="0"/>
					<xs:element name="definition" type="C_COMPLEX_OBJECT"/>
					<xs:element name="invariants" type="ASSERTION" minOccurs="0"
						maxOccurs="unbounded"/>
					<xs:element name="ontology" type="ARCHETYPE_ONTOLOGY"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="ARCHETYPE_CONSTRAINT" abstract="true">
		<xs:sequence/>
	</xs:complexType>
	<xs:complexType name="C_OBJECT" abstract="true">
		<xs:complexContent>
			<xs:extension base="ARCHETYPE_CONSTRAINT">
				<xs:sequence>
					<xs:element name="rm_type_name" type="xs:string"/>
					<xs:element name="occurrences" type="IntervalOfInteger"/>
					<xs:element name="node_id" type="xs:string"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="C_ATTRIBUTE" abstract="true">
		<xs:complexContent>
			<xs:extension base="ARCHETYPE_CONSTRAINT">
				<xs:sequence>
					<xs:element name="rm_attribute_name" type="xs:string"/>
					<xs:element name="existence" type="IntervalOfInteger"/>
					<xs:element name="children" type="C_OBJECT" minOccurs="0" maxOccurs="unbounded"
					/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="C_SINGLE_ATTRIBUTE">
		<xs:complexContent>
			<xs:extension base="C_ATTRIBUTE">
				<xs:sequence/>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="C_MULTIPLE_ATTRIBUTE">
		<xs:complexContent>
			<xs:extension base="C_ATTRIBUTE">
				<xs:sequence>
					<xs:element name="cardinality" type="CARDINALITY"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="CARDINALITY">
		<xs:sequence>
			<xs:element name="is_ordered" type="xs:boolean"/>
			<xs:element name="is_unique" type="xs:boolean"/>
			<xs:element name="interval" type="IntervalOfInteger"/>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="C_COMPLEX_OBJECT">
		<xs:complexContent>
			<xs:extension base="C_DEFINED_OBJECT">
				<xs:sequence>
					<xs:element name="attributes" type="C_ATTRIBUTE" minOccurs="0"
						maxOccurs="unbounded"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="ARCHETYPE_SLOT">
		<xs:complexContent>
			<xs:extension base="C_OBJECT">
				<xs:sequence>
					<xs:element name="includes" type="ASSERTION" minOccurs="0" maxOccurs="unbounded"/>
					<xs:element name="excludes" type="ASSERTION" minOccurs="0" maxOccurs="unbounded"
					/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="CONSTRAINT_REF">
		<xs:complexContent>
			<xs:extension base="C_OBJECT">
				<xs:sequence>
					<xs:element name="reference" type="xs:string"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="C_DEFINED_OBJECT">
		<xs:complexContent>
			<xs:extension base="C_OBJECT">
				<xs:sequence/>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="C_PRIMITIVE_OBJECT">
		<xs:complexContent>
			<xs:extension base="C_DEFINED_OBJECT">
				<xs:sequence>
					<xs:element name="item" type="C_PRIMITIVE" minOccurs="0"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="C_DOMAIN_TYPE" abstract="true">
		<xs:complexContent>
			<xs:extension base="C_DEFINED_OBJECT">
				<xs:sequence/>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="ARCHETYPE_INTERNAL_REF">
		<xs:complexContent>
			<xs:extension base="C_OBJECT">
				<xs:sequence>
					<xs:element name="target_path" type="xs:string"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="ASSERTION">
		<xs:sequence>
			<xs:element name="tag" type="xs:string" minOccurs="0"/>
			<xs:element name="string_expression" type="xs:string" minOccurs="0"/>
			<xs:element name="expression" type="EXPR_ITEM"/>
			<xs:element name="variables" type="ASSERTION_VARIABLE" minOccurs="0"
				maxOccurs="unbounded"/>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="EXPR_ITEM" abstract="true">
		<xs:sequence>
			<xs:element name="type" type="xs:string"/>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="ASSERTION_VARIABLE">
		<xs:sequence>
			<xs:element name="name" type="xs:string"/>
			<xs:element name="definition" type="xs:string"/>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="EXPR_LEAF">
		<xs:complexContent>
			<xs:extension base="EXPR_ITEM">
				<xs:sequence>
					<xs:element name="item" type="xs:anyType"/>
					<xs:element name="reference_type" type="xs:string"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="EXPR_OPERATOR" abstract="true">
		<xs:complexContent>
			<xs:extension base="EXPR_ITEM">
				<xs:sequence>
					<xs:element name="operator" type="OPERATOR_KIND"/>
					<xs:element name="precedence_overridden" type="xs:boolean"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="EXPR_UNARY_OPERATOR">
		<xs:complexContent>
			<xs:extension base="EXPR_OPERATOR">
				<xs:sequence>
					<xs:element name="operand" type="EXPR_ITEM"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="EXPR_BINARY_OPERATOR">
		<xs:complexContent>
			<xs:extension base="EXPR_OPERATOR">
				<xs:sequence>
					<xs:element name="left_operand" type="EXPR_ITEM"/>
					<xs:element name="right_operand" type="EXPR_ITEM"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:simpleType name="OPERATOR_KIND">
		<xs:restriction base="xs:integer">
			<xs:enumeration value="2001" id="equal"/>
			<xs:enumeration value="2002" id="not_equal"/>
			<xs:enumeration value="2003" id="less_than_or_equal"/>
			<xs:enumeration value="2004" id="less_than"/>
			<xs:enumeration value="2005" id="greater_than_or_equal"/>
			<xs:enumeration value="2006" id="greater_than"/>
			<xs:enumeration value="2007" id="matches"/>
			<xs:enumeration value="2010" id="not"/>
			<xs:enumeration value="2011" id="and"/>
			<xs:enumeration value="2012" id="or"/>
			<xs:enumeration value="2013" id="xor"/>
			<xs:enumeration value="2014" id="implies"/>
			<xs:enumeration value="2015" id="for_all"/>
			<xs:enumeration value="2016" id="exists"/>
			<xs:enumeration value="2020" id="plus"/>
			<xs:enumeration value="2021" id="minus"/>
			<xs:enumeration value="2022" id="multiply"/>
			<xs:enumeration value="2023" id="divide"/>
			<xs:enumeration value="2024" id="exponent"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="VALIDITY_KIND">
		<xs:restriction base="xs:integer">
			<xs:enumeration value="1001" id="mandatory"/>
			<xs:enumeration value="1002" id="optional"/>
			<xs:enumeration value="1003" id="disallowed"/>
		</xs:restriction>
	</xs:simpleType>

	<xs:complexType name="C_PRIMITIVE" abstract="true">
		<xs:sequence/>
	</xs:complexType>
	<xs:complexType name="C_BOOLEAN">
		<xs:complexContent>
			<xs:extension base="C_PRIMITIVE">
				<xs:sequence>
					<xs:element name="true_valid" type="xs:boolean"/>
					<xs:element name="false_valid" type="xs:boolean"/>
					<xs:element name="assumed_value" type="xs:boolean" minOccurs="0"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="C_STRING">
		<xs:complexContent>
			<xs:extension base="C_PRIMITIVE">
				<xs:sequence>
					<xs:element name="pattern" type="xs:string" minOccurs="0"/>
					<xs:element name="list" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
					<xs:element name="list_open" type="xs:boolean" minOccurs="0"/>
					<xs:element name="assumed_value" type="xs:string" minOccurs="0"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="C_INTEGER">
		<xs:complexContent>
			<xs:extension base="C_PRIMITIVE">
				<xs:sequence>
					<xs:element name="list" type="xs:int" minOccurs="0" maxOccurs="unbounded"/>
					<xs:element name="range" type="IntervalOfInteger" minOccurs="0"/>
					<xs:element name="assumed_value" type="xs:int" minOccurs="0"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="C_REAL">
		<xs:complexContent>
			<xs:extension base="C_PRIMITIVE">
				<xs:sequence>
					<xs:element name="list" type="xs:float" minOccurs="0" maxOccurs="unbounded"/>
					<xs:element name="range" type="IntervalOfReal" minOccurs="0"/>
					<xs:element name="assumed_value" type="xs:float" minOccurs="0"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="C_DATE">
		<xs:complexContent>
			<xs:extension base="C_PRIMITIVE">
				<xs:sequence>
					<xs:element name="pattern" type="DateConstraintPattern" minOccurs="0"/>
					<xs:element name="timezone_validity" type="VALIDITY_KIND" minOccurs="0"/>
					<xs:element name="range" type="IntervalOfDate" minOccurs="0"/>
					<xs:element name="assumed_value" type="Iso8601Date" minOccurs="0"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:simpleType name="DateConstraintPattern">
		<xs:restriction base="xs:string">
			<xs:pattern value="[yY][yY][yY][yY]-[mM?X][mM?X]-[dD?X][dD?X]"/>
		</xs:restriction>
	</xs:simpleType>

	<xs:complexType name="C_DATE_TIME">
		<xs:complexContent>
			<xs:extension base="C_PRIMITIVE">
				<xs:sequence>
					<xs:element name="pattern" type="DateTimeConstraintPattern" minOccurs="0"/>
					<xs:element name="timezone_validity" type="VALIDITY_KIND" minOccurs="0"/>
					<xs:element name="range" type="IntervalOfDateTime" minOccurs="0"/>
					<xs:element name="assumed_value" type="Iso8601DateTime" minOccurs="0"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:simpleType name="DateTimeConstraintPattern">
		<xs:restriction base="xs:string">
			<xs:pattern
				value="[yY][yY][yY][yY]-[mM?][mM?]-[dD?X][dD?X][T][hH?X][hH?X]:[mM?X][mM?X]:[sS?X][sS?X]"
			/>
		</xs:restriction>
	</xs:simpleType>

	<xs:complexType name="C_TIME">
		<xs:complexContent>
			<xs:extension base="C_PRIMITIVE">
				<xs:sequence>
					<xs:element name="pattern" type="TimeConstraintPattern" minOccurs="0"/>
					<xs:element name="timezone_validity" type="VALIDITY_KIND" minOccurs="0"/>
					<xs:element name="range" type="IntervalOfTime" minOccurs="0"/>
					<xs:element name="assumed_value" type="Iso8601Time" minOccurs="0"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:simpleType name="TimeConstraintPattern">
		<xs:restriction base="xs:string">
			<xs:pattern value="[hH][hH]:[mM?X][mM?X]:[sS?X][sS?X]"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:complexType name="C_DURATION">
		<xs:complexContent>
			<xs:extension base="C_PRIMITIVE">
				<xs:sequence>
					<xs:element name="pattern" type="DurationConstraintPattern" minOccurs="0"/>
					<xs:element name="range" type="IntervalOfDuration" minOccurs="0"/>
					<xs:element name="assumed_value" type="Iso8601Duration" minOccurs="0"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:simpleType name="DurationConstraintPattern">
		<xs:restriction base="xs:string">
			<xs:pattern value="(P[yY]?[mM]?[wW]?[dD]?T[hH]?[mM]?[sS]?)|(P[yY]?[mM]?[wW]?[dD]?)"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:complexType name="ARCHETYPE_ONTOLOGY">
		<xs:sequence>
			<xs:element name="term_definitions" type="CodeDefinitionSet" maxOccurs="unbounded"/>
			<xs:element name="constraint_definitions" type="CodeDefinitionSet" minOccurs="0"
				maxOccurs="unbounded"/>
			<xs:element name="term_bindings" type="TermBindingSet" minOccurs="0"
				maxOccurs="unbounded"/>
			<xs:element name="constraint_bindings" type="ConstraintBindingSet" minOccurs="0"
				maxOccurs="unbounded"/>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="CodeDefinitionSet">
		<xs:sequence>
			<xs:element name="items" type="ARCHETYPE_TERM" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="language" type="xs:string" use="required"/>
	</xs:complexType>
	<xs:complexType name="ARCHETYPE_TERM">
		<xs:sequence>
			<xs:element name="items" type="StringDictionaryItem" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="code" type="xs:string" use="required"/>
	</xs:complexType>
	<xs:complexType name="TermBindingSet">
		<xs:sequence>
			<xs:element name="items" type="TERM_BINDING_ITEM" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="terminology" type="xs:string" use="required"/>
	</xs:complexType>
	<xs:complexType name="TERM_BINDING_ITEM">
		<xs:sequence>
			<xs:element name="value" type="CODE_PHRASE"/>
		</xs:sequence>
		<xs:attribute name="code" type="xs:string" use="required"/>
	</xs:complexType>
	<xs:complexType name="ConstraintBindingSet">
		<xs:sequence>
			<xs:element name="items" type="CONSTRAINT_BINDING_ITEM" minOccurs="0"
				maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="terminology" type="xs:string" use="required"/>
	</xs:complexType>
	<xs:complexType name="CONSTRAINT_BINDING_ITEM">
		<xs:sequence>
			<xs:element name="value" type="xs:anyURI"/>
		</xs:sequence>
		<xs:attribute name="code" type="xs:string" use="required"/>
	</xs:complexType>
</xs:schema>
